package matlap.server;

import matlap.client.services.user.UserService;
import matlap.database.dao.DAOFactory;
import matlap.database.dao.UserDAO;
import matlap.shared.User;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class UserServiceImpl extends RemoteServiceServlet implements
		UserService {
	DAOFactory df = DAOFactory.getInstance();
	UserDAO ud = df.getUserDAO();

	/**
	 * Checks the users username and password at the login.
	 */
	@Override
	public User loginUser(String userName, String password) {
		return ud.loginUser(userName, password);
	}

	/**
	 * Turns back a User from registered and people tables by adding username.
	 */
	@Override
	public User getUser(String userName) {
		return ud.getUser(userName);
	}

	/**
	 * Updates a user in people and registered tables by adding User;
	 */
	public void updateUser(User user) {
		ud.updateUser(user);
	}
}